<template>
  <div class="card-box">
    <div class="mask-box"></div>
    <div
      v-if="cardData.card_title"
      class="main"
      :style="{ 'background-image': `url(${cardData.card_cover_picture})` }"
    >
      <!-- <div class="lb-box">待激活</div> -->
      <div class="info-box">
        <div class="left">
          <img
            mode="scaleToFill"
            :src="cardData.merchant.logo"
            class="img-size-100"
          />
        </div>
        <div class="right">
          <div class="title">{{ cardData.merchant.name }}</div>
          <div class="subtitle">
            {{ cardData.card_title }}
          </div>
          <div>
            <div class="label">{{ cardData.product_specification_title }}</div>
          </div>
        </div>
      </div>
      <div class="footer-box">卡券号 {{ cardData.card_no }}</div>
    </div>
  </div>
</template>
<script>
export default {
  props: { cardId: String },
  data() {
    return {
      cardData: {}
    };
  },
  watch: {
    cardId(n) {
      if (n) {
        this.getCardInfo();
      }
    }
  },
  methods: {
    getCardInfo() {
      this.$api.getCardInfo({ card_id: this.cardId }).then(res => {
        if (res.code == 200) {
          this.cardData = res.data;
          this.$emit("sendCouponInfo", res.data);
        }
      });
    }
  }
};
</script>
<style lang="scss">
.card-box {
  height: 320rpx;
  border-radius: 20rpx;
  overflow: hidden;
  background: #dedede;
  margin-bottom: 40rpx;
  position: relative;
  .main {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    padding: 32rpx 28rpx;
    box-sizing: border-box;
    background-size: 100% auto;
    background-position: left top;
  }
  .mask-box {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      180deg,
      rgba(0, 0, 0, 1) 0%,
      rgba(0, 0, 0, 0) 100%
    );
    opacity: 0.5;
    z-index: 1;
  }
  .lb-box {
    color: #fff;
    line-height: 40rpx;
    height: 40rpx;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20rpx;
    padding: 0 14rpx;
    position: absolute;
    top: 32rpx;
    right: 40rpx;
  }
  .info-box {
    display: flex;
    .left {
      flex: 0 0 80rpx;
      height: 80rpx;
      border-radius: 50%;
      border: 2rpx solid #fff;
      overflow: hidden;
    }
    .right {
      color: #fff;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-left: 10rpx;
      .title {
        font-size: 32rpx;
        margin-bottom: 6rpx;
      }
      .subtitle {
        font-size: 28rpx;
        opacity: 0.8;
      }
    }
    .label {
      display: inline-block;
      padding: 0 10rpx;
      font-size: 24rpx;
      border-radius: 6rpx;
      border: 1px solid rgba(255, 255, 255, 1);
      background: rgba(0, 0, 0, 0.2);
      opacity: 0.6;
      white-space: nowrap;
    }
  }
  .footer-box {
    font-size: 28rpx;
    height: 60rpx;
    position: absolute;
    bottom: 10rpx;
    left: 30rpx;
    width: 100%;
    color: #fff;
    display: flex;
    text-align: center;
    align-items: center;
  }
}
</style>
